package model.play
{
	import core.Model;
	
	import events.PlayEvent;
	
	import flash.events.EventDispatcher;
	
	import utils.ai.CardTools;

	public class PlayerModel extends EventDispatcher
	{
		private var _model:Model = Model.getInstance();
		private var _currentHoldCardDatas:Array;
		
		public function PlayerModel()
		{
			
		}
		
		public function broke():void
		{
			var playEvent:PlayEvent = new PlayEvent(PlayEvent.BROKE);
			dispatchEvent(playEvent);
		}
		
		public function showShopItemList(datas:Array):void
		{
			var playEvent:PlayEvent = new PlayEvent(PlayEvent.SHOW_SHOP_ITEM_LIST);
			playEvent.cardDatas = datas;
			dispatchEvent(playEvent);
		}
		
		public function showRecordCards(datas:Array):void
		{
			var playEvent:PlayEvent = new PlayEvent(PlayEvent.SHOW_RECORD_CARDS);
			playEvent.cardDatas = datas;
			dispatchEvent(playEvent);
		}
		
		public function showPlayerCards(cardDatas:Array):void
		{
			_currentHoldCardDatas = cardDatas;
			var playEvent:PlayEvent = new PlayEvent(PlayEvent.SHOW_PLAYER_CARDS);
			playEvent.cardDatas = cardDatas;
			dispatchEvent(playEvent);
		}
		
		public function get currentHoldCardDatas():Array
		{
			return _currentHoldCardDatas;
			if (_currentHoldCardDatas)
			{
				return CardTools.cloneCardDatas(_currentHoldCardDatas);
			}
			return null;
		}
		
		public function sendPlayCards(cardDatas:Array):void
		{
			_model.netRemote.sendPlayCards(cardDatas);
		}	
		
		public function sendPlayPass():void
		{
			_model.netRemote.sendPlayPass();
		}
		
		public function sendStandUp():void
		{
			_model.netRemote.sendStandUp();
		}
		
		public function clear():void
		{
			_currentHoldCardDatas = null;
		}
	}
}